<%@ page contentType="text/html; charset=utf-8" language="java" import="java.util.*" pageEncoding="utf-8" errorPage="" %>
<%@ page import="club325.webchat.servlet.chatcore.ChatRoom" %>
<%@ page import="club325.webchat.servlet.chatcore.ChatRoomManager" %>
<%@ page session="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Keywords" content="WebChat,Chat" />
<meta http-equiv="Description" content="Chatting on Web" />
<title>聊天室列表</title>
<link href="/WebChat/style/global.css" rel="stylesheet" type="text/css" />
<link href="/WebChat/style/chat_lib.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="roomlist">
<%
	String[] rooms = ChatRoomManager.getInstance().getChatRooms(ChatRoomManager.SUBJECT_ROOM_CHAT);
	
	if (rooms != null && rooms.length > 0) {
%>
  <ul>
<%
		for (int i = 0; i < rooms.length; i++) {
			ChatRoom room = ChatRoomManager.getInstance().getChatRoom(ChatRoomManager.SUBJECT_ROOM_CHAT + rooms[i]);
			if (room != null) {
				int size = room.size();
				String memberSize = null;
				String info = rooms[i] + " - " + room.getRoomCreator();
				
				if (size < 2) {
					memberSize = "few";
				} else if (size >=2 && size <=5) {
					memberSize = "normal";
				} else {
					memberSize = "many";
				}
%>
    <li class=<%= memberSize %>><a href="/WebChat/lib/chat_roomcheck.jsp?name=<%= rooms[i].substring(1) %>&creator=<%= room.getRoomCreator() %>&subject=<%= ChatRoomManager.SUBJECT_ROOM_CHAT +rooms[i] %>" target="chat_roomcheck"><%= info %></a></li>
<%
			}
		}
%>
  </ul>
<% 
	} else {
%>
  <h1>当前没有聊天室...</h1>
<%
	}
%>
</div>
</body>
</html>